﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<LiteratureManage.Domain.Models.Literature>" %>

<fieldset style="width:1000px;">
<legend>文献作者：</legend>
<div>
<div style="text-align:right;padding:0 0 2px 0;">
    [<%=Html.ActionLink("添加作者", MVC.Literature.CreateAuthor(Model.Id), new { @class = "fixedAjaxDOMWindow" })%>]
</div>   
<div style="padding:2px 2px 5px 2px;">
<table class="table">
    <thead>
        <tr>
            <th style="width:80px;">姓名</th>
            <th style="width:40px;">性别</th>
            <th style="width:150px;">联系单位</th>
            <th style="width:100px;">联系电话</th>
            <th style="width:100px;">联系手机</th>
            <th style="width:auto;">联系地址</th>
            <th style="width:70px;">操作</th>
        </tr>
    </thead>
    <%if (Model != null && Model.Authors != null && Model.Authors.Count > 0)
      {
          foreach (var author in Model.Authors)
          {%>
         <tr>
            <td><%=author.Name%></td>
            <td><%=author.Gender == 0 ? "男" : "女"%></td>
            <td><%=author.Org%></td>
            <td><%=author.Phone %></td>
            <td><%=author.Mobile %></td>
            <td><%=author.Address %></td>
            <td>
                <%=Html.ActionLink("修改", MVC.Literature.EditAuthor(Model.Id, author.Id), new { @class="fixedAjaxDOMWindow"})%>
                <a href="javascript:void(0);" deleteFor="<%=author.Id %>" class="deleteThis">删除</a>
            </td>
         </tr>
    <%  }
      }
      else
      {
         %>
         <tr style="height:150px;">
            <td colspan="7">暂无任何数据</td>
        </tr>
    <%} %>
</table>    
</div>
</div>   
</fieldset>
<script type="text/javascript">
    $(function() {
        $(".deleteThis").click(function() {
            if(confirm("确定要删除吗")){
                var url = "<%=Url.Action(MVC.Literature.DeleteAuthor()) %>";
                $.post(
                url,
                { "literatureId":<%=Model.Id %>,"id": $(this).attr("deleteFor") },
                function(data) {
                    if (data.state == 100) {
                        window.location = data.data.url;
                    }
                    else {
                        alert(data.message);
                    }
                },
                "json");
            }
        });
    });
</script>
